package service;

import dao.UserDao;
import dao.UserDaoImpl;
import pojo.User;

/**
 * @author: zen
 * @date: 2020/4/12
 * @Title: LoginManagement
 * @Description: 登录注册管理
 */
public class LoginManagement {

    private static UserDao userDao = new UserDaoImpl();
    /**
     * 登录
     * @param account
     * @param pass
     * @return
     */
    public static boolean login(String account, String pass) {
        boolean isExistence = userDao.isExistence(account, pass);
        return isExistence;
    }

    /**
     * 检查账号是否可用
     * @param account
     * @return
     */
    public static boolean checkUser(String account) {
        boolean isExistence = userDao.isExistence(account);
        return isExistence;
    }

    /**
     * 注册
     * @param user
     * @return
     */
    public static boolean registry(User user) {
        boolean result = userDao.addUser(user);
        return result;
    }

    /**
     * 获取用户信息
     * @param account   用户账号
     * @return
     */
    public static User getUser(String account) {
        User user = userDao.getUserByAccount(account);
        return user;
    }
}
